package com.xqx.user.controller;

import com.xqx.user.pojo.User;
import com.xqx.user.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author：xingquanxiang createTime：2019/10/14 14:29
 * description:
 */
@RestController
@RequestMapping("/user")
@RefreshScope
public class UserController {
    @Autowired
    private UserService userService;

    @Value("${test.name}")
    private String name;

    @GetMapping("/find/{id}")
    public User findById(@PathVariable Long id){
        System.out.println("云配置文件：name="+name);
        System.out.println("请求来了1122");
        User dbUser = userService.findById(id);
        System.out.println("dbUser = " + dbUser);
        return dbUser;
    }


    @RequestMapping("/save")
    public boolean save(User user){
        return userService.save(user);
    }
}
